From 4b3986ae1fa880888b4b37e37e54937b4fe34dcf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Tue, 4 Jun 2019 16:32:49 +0200 Subject: [PATCH] rendernodeimpl: Inline container_node_get_bounds into _new It's the only caller of the function and we can avoid a second loop over all child nodes this way. --- gsk/gskrendernodeimpl.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/gsk/gskrendernodeimpl.c b/gsk/gskrendernodeimpl.c index 0a432306ee..d08ca9073a 100644 --- a/gsk/gskrendernodeimpl.c +++ b/gsk/gskrendernodeimpl.c @@ -1776,23 +1776,6 @@ gsk_container_node_diff (GskRenderNode *node1, gsk_render_node_diff_impossible (node1, node2, region); } -static void -gsk_container_node_get_bounds (GskContainerNode *container, - graphene_rect_t *bounds) -{ - guint i; - - if (container->n_children == 0) - { - graphene_rect_init_from_rect (bounds, graphene_rect_zero()); - return; - } - - graphene_rect_init_from_rect (bounds, &container->children[0]->bounds); - for (i = 1; i < container->n_children; i++) - graphene_rect_union (bounds, &container->children[i]->bounds, bounds); -} - static const GskRenderNodeClass GSK_CONTAINER_NODE_CLASS = { GSK_CONTAINER_NODE, sizeof (GskContainerNode), @@ -1824,10 +1807,24 @@ gsk_container_node_new (GskRenderNode **children, container->n_children = n_children; - for (i = 0; i < container->n_children; i++) - container->children[i] = gsk_render_node_ref (children[i]); + if (n_children == 0) + { + graphene_rect_init_from_rect (&container->render_node.bounds, graphene_rect_zero()); + } + else + { + graphene_rect_t bounds; - gsk_container_node_get_bounds (container, &container->render_node.bounds); + container->children[0] = gsk_render_node_ref (children[0]); + graphene_rect_init_from_rect (&bounds, &container->children[0]->bounds); + for (i = 1; i < n_children; i++) + { + container->children[i] = gsk_render_node_ref (children[i]); + graphene_rect_union (&bounds, &children[i]->bounds, &bounds); + } + + graphene_rect_init_from_rect (&container->render_node.bounds, &bounds); + } return &container->render_node; } -- 2.30.2